package net.suncaper.demo.controller;

import net.suncaper.demo.domain.MediumInspection;
import net.suncaper.demo.service.GraduateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/graduate")
public class Graduate_controller {
    @Autowired
    GraduateService graduateService;
    @RequestMapping("/addstudentmedium")
    public String addstudentmedium(){
        return "pages/graduate/addstudentmedium.html";
    }
    @PostMapping("/addstudentmedium")
    public String savestudentmedium(MediumInspection mediumInspection){
        mediumInspection.setStudentId("3");
        mediumInspection.setSelectQuestionId(graduateService.findSelectQuestionByid("3"));
        graduateService.saveMediumInspection(mediumInspection);
        return "redirect:/graduate/studentmedium";
    }
    @RequestMapping("/studentmedium")
    public String aa(Model model){
        MediumInspection mediumInspection=graduateService.findMediumInspectionById(graduateService.findMediumInspectionByStudentId("3"));
        model.addAttribute("mediumInspection",mediumInspection);
        return "pages/graduate/studentmedium.html";
    }
    private int select;
    private String UserId;

    @RequestMapping("/set")
    public String SetAdministratorId(@RequestParam(value = "UserId", required = false) String UserId, @RequestParam(value = "select", required = false) int select) {
        this.UserId=UserId;
        this.select=select;
        return "redirect:/information";
    }
}
